'use strict';

var config = require('./config'),
    mongoose = require('mongoose');

//Load the application models
require('../../../user/server/models/client.server.model');
require('../../../dish/server/models/dish.server.model');
require('../../../order/server/models/order.server.model');
require('../../../merchant/server/models/merchant.server.model');

module.exports = function(fn) {
    var db = mongoose.connect(config.mongodb, fn);
    mongoose.connection.on('error', function () {
        console.log('Connection to DB ' + config.mongodb + ' error !');
    });

    mongoose.connection.on('connected', function () {
        console.log('Mongoose connected to ' + config.mongodb);
    });
};